﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlexiCommerce.Components;
using System.Globalization;
using System.Resources;

namespace FlexiCommerce.Localization
{
    public class LocalizationManager : ILocalizationManager
    {
        #region ILocalizationManager Members

        public bool UseSystemLanguagePersistence
        {
            get { return true; }
        }

        public IEnumerable<FlexiCommerce.Components.Culture> ConfiguredCultures()
        {
            foreach (Language lan in Find.Languages.ToList())
            {
                yield return lan.Culture;
            }  
        }

        #endregion

        #region ILocalizationManager Members


        public string GetResource(string resourceName)
        {
            return FlexiCommerce.Localization.Resources.GetResource(resourceName);
        }

        public CultureInfo CurrentContextLanguage
        {
            get
            {
                return System.Threading.Thread.CurrentThread.CurrentUICulture;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string GetResource(string resourceName, CultureInfo culture)
        {
            return FlexiCommerce.Localization.Resources.GetResource(resourceName, culture);
        }

        #endregion
    }
}
